#ifndef WIDGET_H
#define WIDGET_H
#include "actionwidget.h"
#include <QWidget>
#include <QFile>
#include <QTcpSocket>
#include <QMutex>
#include "protocol.h"
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
//声明调用
class TcpClient;
//
QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE

class Widget : public QWidget
{
    Q_OBJECT

public:

    Widget(QWidget *parent = nullptr);

    ~Widget();

    static Widget* get_instance();



public slots:

    void TcpConnectStatus();

    void TcpConnectFailStatus(QString cause);

//    void RecvMsg();
public slots:
    void ActForRegisterFail(QString info);

    void ActForRegisterSuccess(QString info);

    void ActForLoginFail(QString info);

    void ActForLoginSuccess(QString info);


private slots:
    void on_LoginBtn_clicked();

    void on_DeleteBtn_clicked();

    void on_RegisterBtn_clicked();

    void on___register_clicked();

    void on___login_clicked();


private:
    Ui::Widget *ui;

    TcpClient* tcpclient;

    static Widget * UserUpSet;

    static QMutex UserUpSetMutex;

    ActionWidget *UserAction;

    void EnterUserAction();

    static void destroy_instance();

    void LinkTcpSignalAndSlot();
signals:
    void sig_register(myuint Type,QJsonObject Info);
    //void EmitRegisterRequest(QString UserName,QString Pwd);
    void sig_Login(myuint Type,QJsonObject Info);
//    void EmitLoginRequest(QString UserName,QString Pwd);



};
#endif // WIDGET_H
